package io;

import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.nio.charset.StandardCharsets;

/**
 * 通过字符转换流将一些字符串写入到指定文件
 */
public class OutputStreamWriterDemo01 {
    public static void main(String[] args) throws IOException {
        //1.构建字符转换输出流对象
        OutputStreamWriter osw =
                new OutputStreamWriter(
                        new FileOutputStream("./osw.txt"),
                              StandardCharsets.UTF_8);
        //2.写数据(字符串)
        osw.write("你好");//alt+enter
        osw.write("子千老师");
        System.out.println("数据写出完毕");
        //3.关闭流对象
        osw.close();
    }
}
